
* ====================================================
* Project: MOTIVATED BELIEFS ABOUT STOCK RETURNS
* Purpose: Reproduce all figures, tables and tests of Study 1
* Authors: Carlos Cueva & Iñigo Iturbe-Ormaetxe
* Date: 2025-04-10
* Stata Version: 16
* ====================================================


* ====================================================
* 1. Clear environment
* ====================================================
clear all

* ====================================================
* 2. Set path & load data
* ====================================================

cd "your_pathname"

use Study_1_Data.dta

*Build target variable
gen target = 0
replace target = best if treatment==0
replace target = 1 if owned==1 & treatment==1
replace target = 1 if owned==1 & best==1 & treatment==2

*drop subject quest21 quest31 quest41 luck self_regard self_confidence comment treatment_number

* ====================================================
* 3. Description of variables in the dataset
* ====================================================

*session: indicators of the 18 sessions
*subject: individual position in the lab, takes values {1,2,..,24} (lab capacity is 24)
*period: prediction period, takes values {1,2,..,20}
*stock: stock indicator, takes values {1,2,3,4,5,6}
*price: current stock price
*guessup: takes value 1 if the subject guesses UP and value 0 if the subject guesses DOWN
*buy: takes value 1 if subject buys the stock in period 10 in treatments Ownership&Choice or in period 20 in treatment Baseline
*client: computer used by the subject in the lab
*Age
*quest21: gender, for males quest21=="Masculino", for females quest21=="Femenino"
*quest31: level of studies, for undergrads quest31=="Grado", for postgrads quest31=="Posgrado", for others quest31=="Otro"
*quest41: field of studies
*ability: self-reported ability to make good decisions in the experiment, takes values {1,2,..,10} where 0 is "very bad" and 10 is "very good"
*luck: self-reported luck in the experiment, takes values {1,2,..,10} where 0 is "very bad luck" and 10 is "very good luck"
*self_regard: self-reported feelings,  takes values {1,2,..,10} where 0 is "very negative" and 10 is "very positive"
*self_confidence: self-reported ability to choose good investments, takes values {1,2,..,10} where 0 is "very bad" and 10 is "very good"
*financial_lit1, financial_lit2, financial_lit3, crt1, crt2, crt3: answers to financial literacy test and crt test
*comment: final comments made by participants (free text)
*treatment_number: session labels, Baseline treatment has labels BUY_1 to BUY_6, Ownership has ALLOCATE_1 to ALLOCATE_6, Choice has CHOOSE_1 to CHOOSE_6
*female: takes value 0 for males, 1 for females
*undergraduate: takes value 1 for undergrads, 0 otherwise
*field: we use quest41 to build 7 large groups of study fields
*STEM, ECONOMICS, LAW, EDUCATION, HUMANITIES, HEALTH, OTHER_SOCIAL_SCIENCES: dummy variables corresponding to large study fields
*experience: self-reported experience investing in the stock market (None (0), a little (1), some (2), a lot (3))
*future_invest: self-reported  interest in investing in the stock market in the future (Definitely not (0), not very likely (1), quite likely (2), very likely (3), definitely yes (4)
*fin1, fin2, fin3, crt1_right, crt2_right, crt3_right: dummy variables that take value 1 if the corresponding answer is the right one
*time: number of seconds to make the guess
*id: individual identifier, takes values from 1 to 409
*up: takes value 1 if the price goes UP, 0 otherwise
*ups: accumulated number of periods the stock has had a price increase
*downs: accumulated number of periods the stock has had a price decrease
*bayesian_posterior: it is calculated as (ups+1)/(ups+downs+2)
*treatment: treatment indicator, Baseline=0, Choice=1, Ownership=2
*owned: takes value 1 if the subject owns the stock; in the Baseline treatment is always 0
*best: takes value 1 if the subject chooses as one og the best three stock
*sell: takes value 1 if the subject decides to sell in period 20. It is not defined in the Baseline treatment
*post: takes value 0 in periods 1-10 and value 1 in periods 11-20
*target: takes value 1 in Baseline if best==1, in Ownership if best==1&owned==1, in Choice if owned==1
*sessionid: chronological order of sessions, takes values {1,2,..,18}
*periodsession: period times sessionid, takes values {1,2,..,360}
*buyprice: price at which the subject bought the stocks
*loss: takes value 1 if current price below purchase price
*pricediff: price - buyprice in periods 11-20
*meanpricediff: mean of pricediff, defined for each stock and subject
*minpricediff: minimum value of pricediff, defined for each stock and subject
*maxpricediff: maximum value of pricediff, defined for each stock and subject
*stockgroup: divides all stocks into three groups according to the value of meanpricediff, takes value 1 in 1st tertile, 2 in the 2nd, 3 in the 3rd
*badstock: takes value 1 if bayesian_posterior<.5
*guessrat: takes value 1 if bayesian_posterior>.5, value 0 if bayesian_posterior<.5, value 0.5 if bayesian_posterior==.5
*bayes_up: takes value 1 if bayesian_posterior>.5
*bayes_down: takes value 1 if bayesian_posterior<.5
*idstock: id times stock, takes values {1,2,..,2454}
*guessdiff = guessup-guessrat
*numguesses: number of guesses made by the subject, takes values {6,72,78,90,96,102,108,114,120}; the value is 120 if the subjec makes all the guesses
*finlit=fin1+fin2+fin3
*crt = crt1_right + crt2_right + crt3_right
*high_crt = 1 if = crt>2; i.e., if the subject answers correctly the 3 questions of the CRT
*high_finlit = 1 if finlit>2; i.e., if the subject answers correctly the 3 questions of the FLT
*fin_crt = (crt + finlit)/6
*high_fincrt = 1 if the subject is above percentile 66 of the distribution of fin_crt
*experienced = 1 if experience>0
*will_invest = 1 if future_invest>1

exit

* ====================================================
* 4. Figures and tables in the main text
* ====================================================


*****************************************************************************************************************************
******************         Figure 1 in the main text: Mean predictions by period                           ******************
*****************************************************************************************************************************

preserve
*We remove stocks never owned in treatments Ownership and Choice
drop if owned==0&treatment>0
collapse guessup guessrat guessdiff bayesian_posterior (semean) seup = guessup ///
(semean) sediff = guessdiff (semean) sebayes = bayesian_posterior ///
(semean) serat = guessrat, by(treatment period)
gen gh = guessup + seup
gen gl = guessup - seup
gen bh = bayesian_posterior + sebayes
gen bl = bayesian_posterior - sebayes
gen rh = guessrat + serat
gen rl = guessrat - serat
grstyle init
grstyle set plain

twoway ///
(rcap gh gl period if treatment==0, lcolor(green) lw(thin)) ///
(rcap gh gl period if treatment==1, lcolor(cranberry) lw(thin)) ///
(rcap gh gl period if treatment==2, lcolor(midblue) lw(thin)) ///
(connected guessup period if treatment==0, lcolor(green) m(O) mcolor(green) lp(dot) lw(thick)) ///
(connected guessup period if treatment==1, lcolor(cranberry) m(T) mcolor(cranberry)) ///
(connected guessup period if treatment==2, lcolor(midblue) m(S) mcolor(midblue) lp(dash)), ///
xlabel(1 5 10 15 20) ///
legend(rows(1) region(lwidth(none)) order (4 5 6) ///
label(4 "Baseline") label(5 "Choice") label(6 "Ownership")) ///
title("") name(Fig3_1, replace)
restore

*****************************************************************************************************************************
********************************  Section 2.3: Diff-in-Diff Ownership vs. Baseline        ***********************************
*****************************************************************************************************************************

preserve
*We remove treatment Choice
drop if treatment == 1
drop if owned==0&treatment==2
*We exclude 8 subjects who failed to provide predictions on more than two (out of 20) periods
*drop if exclude==1
collapse guessup, by(id treatment post)
gen guess_pre = guessup if post==0
gen guess_post = guessup if post==1
collapse guess_pre guess_post, by(id treatment)
gen diffguess = guess_post - guess_pre
ttest guess_pre, by(treatment) 
ranksum guess_pre, by(treatment)
ranksum guess_pre, by(treatment) exact
ttest guess_post, by(treatment)
ranksum guess_post, by(treatment) 
 ranksum guess_post, by(treatment) exact
*Diff-in-diff
ttest diffguess, by(treatment)
ranksum diffguess, by(treatment)
ranksum diffguess, by(treatment) exact
restore


*****************************************************************************************************************************
***************************   Table 1 in the main text: Treatment effects on predictions        ****************************
*****************************************************************************************************************************
 
*ALL STOCKS
preserve
*Multiply guessup by 100 for presentation purposes
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
outreg2 using Reg_lab, adjr2 excel ctitle(All) stats(coef se) dec(3) replace
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*WINNERS (BAYES)
preserve
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
outreg2 using Reg_lab, adjr2 excel ctitle(Winners (Bayes)) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore
 
*WINNERS (REF. PRICE)
preserve
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
outreg2 using Reg_lab, adjr2 excel ctitle(Paper Gains) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOSERS (BAYES)
preserve
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
outreg2 using Reg_lab, adjr2 excel ctitle(Losers) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOSERS (REF. PRICE)
preserve
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
outreg2 using Reg_lab, adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore


*****************************************************************************************************************************
***************     Table 4 (top panel) in the main text and Table E.2 in the Internet Appendix:        *********************
***************                Treatment effects conditioning on target stocks                          *********************
*****************************************************************************************************************************

*ALL STOCKS
preserve
replace guessup = 100*guessup
reghdfe guessup i.target##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
outreg2 using Reg_lab_1, adjr2 excel ctitle(All) stats(coef se) dec(3) replace
*Diff-in-diff Choice vs Baseline:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] = 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.target#1.post#2.treatment])
test _b[1.post#2.treatment] + _b[1.target#1.post#2.treatment] = 0
*Diff-in-diff Choice vs Ownership:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] = 0
restore

*WINNERS (BAYES)
preserve
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.target##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
outreg2 using Reg_lab_1, adjr2 excel ctitle(Pred_rat=1) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] = 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.target#1.post#2.treatment])
test _b[1.post#2.treatment] + _b[1.target#1.post#2.treatment] = 0
*Diff-in-diff Choice vs Ownership:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] = 0
restore

*WINNERS (REF. PRICE)
preserve
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.target##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id) coeflegend
outreg2 using Reg_lab_1, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] = 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.target#1.post#2.treatment])
test _b[1.post#2.treatment] + _b[1.target#1.post#2.treatment] = 0
*Diff-in-diff Choice vs Ownership:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] = 0
restore

*LOSERS (BAYES)
preserve
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.target##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
outreg2 using Reg_lab_1, adjr2 excel ctitle(Pred_rat=0) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] = 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.target#1.post#2.treatment])
test _b[1.post#2.treatment] + _b[1.target#1.post#2.treatment] = 0
*Diff-in-diff Choice vs Ownership:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] = 0
restore

*LOSERS (REF. PRICE)
preserve
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.target##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
outreg2 using Reg_lab_1, adjr2 excel ctitle(Losers) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] = 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.target#1.post#2.treatment])
test _b[1.post#2.treatment] + _b[1.target#1.post#2.treatment] = 0
*Diff-in-diff Choice vs Ownership:
lincom ( _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] )
test _b[1.post#1.treatment] + _b[1.target#1.post#1.treatment] - _b[1.post#2.treatment] - _b[1.target#1.post#2.treatment] = 0
restore


*****************************************************************************************************************************
*******************************   Table E.5 in the Internet Appendix: Heterogeneity   ***************************************
*****************************************************************************************************************************

*1) HIGH FLT vs LOW FLT
*HIGH ABILITY - ALL
preserve
keep if finlit==3
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(All) stats(coef se) dec(3) replace
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - WINNERS (BAYES)
preserve
keep if finlit==3
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - WINNERS (REF. PRICE)
preserve
keep if finlit==3
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab_1, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - LOSERS (BAYES)
preserve
keep if finlit==3
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - LOSERS (REF. PRICE)
preserve
keep if finlit==3
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore



*LOW ABILITY - ALL
preserve
keep if (finlit==0|finlit==1)
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(All) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - WINNERS (BAYES)
preserve
keep if (finlit==0|finlit==1)
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - WINNERS (REF. PRICE)
preserve
keep if (finlit==0|finlit==1)
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab_1, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - LOSERS (BAYES)
preserve
keep if (finlit==0|finlit==1)
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - LOSERS (REF. PRICE)
preserve
keep if (finlit==0|finlit==1)
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

********************************************************************************************************************
*2) EXPERIENCED vs NON-EXPERIENCED
*HIGH ABILITY - ALL
preserve
keep if experienced==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(All) stats(coef se) dec(3) replace
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - WINNERS (BAYES)
preserve
keep if experienced==1
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - WINNERS (REF. PRICE)
preserve
keep if experienced==1
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab_1, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - LOSERS (BAYES)
preserve
keep if experienced==1
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - LOSERS (REF. PRICE)
preserve
keep if experienced==1
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore



*LOW ABILITY - ALL
preserve
keep if experienced==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(All) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - WINNERS (BAYES)
preserve
keep if experienced==0
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - WINNERS (REF. PRICE)
preserve
keep if experienced==0
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab_1, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - LOSERS (BAYES)
preserve
keep if experienced==0
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - LOSERS (REF. PRICE)
preserve
keep if experienced==0
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*******************************************************************************************************************
*3) LIKELY TO INVEST IN THE FUTURE vs UNLIKELY TO INVEST IN THE FUTURE
*HIGH ABILITY - ALL
preserve
keep if will_invest==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(All) stats(coef se) dec(3) replace
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - WINNERS (BAYES)
preserve
keep if will_invest==1
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - WINNERS (REF. PRICE)
preserve
keep if will_invest==1
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab_1, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - LOSERS (BAYES)
preserve
keep if will_invest==1
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - LOSERS (REF. PRICE)
preserve
keep if will_invest==1
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore



*LOW ABILITY - ALL
preserve
keep if will_invest==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(All) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - WINNERS (BAYES)
preserve
keep if will_invest==0
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - WINNERS (REF. PRICE)
preserve
keep if will_invest==0
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab_1, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - LOSERS (BAYES)
preserve
keep if will_invest==0
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - LOSERS (REF. PRICE)
preserve
keep if will_invest==0
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore


*******************************************************************************************************************
*4) STEM+ECON VS REST
*HIGH ABILITY - ALL
preserve
keep if field=="Economics" | field=="STEM"
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(All) stats(coef se) dec(3) replace
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - WINNERS (BAYES)
preserve
keep if field=="Economics" | field=="STEM"
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - WINNERS (REF. PRICE)
preserve
keep if field=="Economics" | field=="STEM"
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab_1, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - LOSERS (BAYES)
preserve
keep if field=="Economics" | field=="STEM"
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*HIGH ABILITY - LOSERS (REF. PRICE)
preserve
keep if field=="Economics" | field=="STEM"
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore



*LOW ABILITY - ALL
preserve
drop if field=="Economics" | field=="STEM"
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(All) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - WINNERS (BAYES)
preserve
drop if field=="Economics" | field=="STEM"
keep if guessrat==1
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - WINNERS (REF. PRICE)
preserve
drop if field=="Economics" | field=="STEM"
drop if post==1 & loss==1
drop if post==1 & price==buyprice
drop if post==0 & price<=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab_1, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - LOSERS (BAYES)
preserve
drop if field=="Economics" | field=="STEM"
keep if guessrat==0
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Winners) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore

*LOW ABILITY - LOSERS (REF. PRICE)
preserve
drop if field=="Economics" | field=="STEM"
drop if post==1 & loss==0
drop if post==0 & price>=100
replace guessup = 100*guessup
reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down, absorb(idstock i.period) cluster(id)
*outreg2 using Reg_lab, adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append
*Diff-in-diff Choice vs Baseline:
lincom (_b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment])
test _b[1.post#1.owned] + _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment]= 0
*Diff-in-diff Ownership vs Baseline:
lincom (_b[1.post#2.treatment] + _b[1.post#1.owned])
test _b[1.post#2.treatment] +  _b[1.post#1.owned] = 0
*Diff-in-diff Choice vs Ownership:
lincom (_b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]))
test _b[1.post#1.treatment] + _b[1.owned#1.post#1.treatment] - (_b[1.post#2.treatment]) = 0
restore


*****************************************************************************************************************************
*************************************      Table 6: Disposition effect     **************************************************
*****************************************************************************************************************************

preserve
drop if owned==0&treatment>0
keep if period==20
replace loss=. if buyprice==price
*hold=1 if does not sell in Ownership&Choice or if buys in Baseline
gen hold = 0 
replace hold = buy if treatment==0
replace hold = 1-sell if treatment>0
collapse hold, by(treatment id loss)
gen hold_loss= hold if loss==1
gen hold_gain = hold if loss==0
collapse hold_loss hold_gain, by(id treatment)
gen DE =  hold_loss - hold_gain
bys treatment: ci mean DE
kwallis DE, by(treatment)
*B v C:
ranksum DE if treatment!=2, by(treatment)
*B v O:
ranksum DE if treatment!=1, by(treatment)
*O v C:
ranksum DE if treatment!=0, by(treatment)

*We test Baseline vs Choice & Ownership together
gen choice_ownership = 0
replace choice_ownership = 1 if (treatment == 1 | treatment == 2)
ranksum DE, by(choice_ownership)

restore


*****************************************************************************************************************************
*******************      Figure 5 in the main text: Proportions of stocks held at the end of each study    ******************
*****************************************************************************************************************************

*1) REGRESSION COEFFICIENTS CORRESPONDING TO EQUATION 4
*NOTE THAT IN PERIOD==20, bayes_up = 1-(bayes_down), so only one of them can be identified 

preserve
drop if owned==0&treatment>0
keep if period==20
replace loss=. if buyprice==price
*hold=1 if does not sell in Ownership&Choice or if buys in Baseline
gen hold = 0 
replace hold = buy if treatment==0
replace hold = 1-sell if treatment>0
replace hold = 100*hold
reg hold i.loss##i.treatment guessup bayesian_posterior bayes_down, vce(cluster id)
*outreg2 using Reg_Figure7_Lab, adjr2 excel ctitle(Study 1) stats(coef se) dec(3) replace
restore

*Top-Left panel, Figure 5
preserve
drop if owned==0&treatment>0
keep if period==20
replace loss=. if buyprice==price
*hold=1 if does not sell in Ownership&Choice or if buys in Baseline
gen hold = 0 
replace hold = buy if treatment==0
replace hold = 1-sell if treatment>0
collapse hold (semean) se = hold, by(treatment loss)
gen hihold = hold+se
gen lohold = hold-se
grstyle init
grstyle set plain
twoway ///
(rcap hihold lohold loss if treatment==0, lc(green)) ///
(rcap hihold lohold loss if treatment==1, lc(cranberry)) ///
(rcap hihold lohold loss if treatment==2, lc(midblue)) ///
(connected hold loss if treatment==0, lc(green) mc(green) m(O)) ///
(connected hold loss if treatment==1, lc(cranberry) mc(cranberry) m(T)) ///
(connected hold loss if treatment==2, lc(midblue) mc(midblue) m(S)) ///
, xlabel(0 "Paper Gains" 1 "Paper Losses")  ///
legend(size(small) rows(1) region(lwidth(none)) order(4 5 6) ///
label(4 "Baseline") label(5 "Choice") label(6 "Ownership")) ///
xtitle("") scale(1) plotregion(margin(l=7 r=7)) ///
subtitle("Means") name(Hold_Study1, replace)
restore

*Top-Right panel, Figure 5
preserve
***NEW***
keep if target==1
*********
drop if owned==0&treatment>0
keep if period==20
replace loss=. if buyprice==price
gen hold = 0 
replace hold = buy if treatment==0
replace hold = 1-sell if treatment>0
reg hold i.loss##i.treatment guessup bayesian_posterior bayes_down, vce(cluster id)
margins loss#treatment, saving(fig5margins, replace)
clear
use fig5margins
rename (_margin _se_margin _m1 _m2) (hold se loss treatment)
gen hi = hold+se
gen lo = hold-se
gen x = 1 if loss==0
replace x = 2 if loss==1

twoway ///
(rcap hi lo x if treatment==0, lc(green)) ///
(rcap hi lo x if treatment==1, lc(cranberry)) ///
(rcap hi lo x if treatment==2, lc(midblue)) ///
(connected hold x if treatment==0, lc(green) mc(green) m(O)) ///
(connected hold x if treatment==1, lc(cranberry) mc(cranberry) m(T)) ///
(connected hold x if treatment==2, lc(midblue) mc(midblue) m(S)) ///
, xlabel(1 "Paper Gains" 2 "Paper Losses")  ///
legend(rows(1) region(lwidth(none)) order(4 5 6) ///
label(4 "Baseline") label(5 "Choice") label(6 "Ownership")) ///
xtitle("") scale(1) plotregion(margin(medium)) ///
subtitle("Margins") name(Hold_Marginsplot1, replace)
restore

grc1leg Hold_Study1 Hold_Marginsplot1, legendfrom(Hold_Marginsplot1) rows(1) ///
title("Study 1", size(*.8)) imargin(r=6 l=6) ycommon scale(1.3) name(Fig5_1_new, replace)

*Need to save this figure as Fig5_1_new.gph in same folder as Study 2 do file
graph save Fig5_1_new.gph, replace


****************************************************************************************************
****************  TABLE E8 IN THE APPENDIX: MEDIATION ANALYSIS  ************************************
****************************************************************************************************

*Conditioning on target stocks
preserve

keep if period==20
keep if target==1
*drop if owned==0&treatment>0
gen hold = 0 
replace hold = buy if treatment==0
replace hold = 1-sell if treatment>0
drop if treatment==2
gen t_target = treatment==1

*All Stocks
medeff (regress guessup t_target bayesian_posterior bayes_down ) ///
(regress hold guessup t_target bayesian_posterior bayes_down) ///
, mediate(guessup) treat(t_target) vce(cluster id)
outreg2 using Reg_med, stnum(replace coef=100*coef) adjr2 excel ctitle(All) stats(coef se) dec(3) append

*Paper Gains:
medeff (regress guessup t_target bayesian_posterior bayes_down) ///
(regress hold guessup t_target bayesian_posterior bayes_down) ///
if price>buyprice, mediate(guessup) treat(t_target) vce(cluster id)
outreg2 using Reg_med, stnum(replace coef=100*coef) adjr2 excel ctitle(Paper Gains) stats(coef se) dec(3) replace

*Paper Losses:
medeff (regress guessup t_target bayesian_posterior bayes_down ) ///
(regress hold guessup t_target bayesian_posterior bayes_down) ///
if price<buyprice, mediate(guessup) treat(t_target) vce(cluster id)
outreg2 using Reg_med, stnum(replace coef=100*coef) adjr2 excel ctitle(Paper Losses) stats(coef se) dec(3) append

restore

*****************************************************************************************************************************
****************************************         ONLINE APPENDIX                    *****************************************
*****************************************************************************************************************************


*****************************************************************************************************************************
******************         TABLE A1. Summary statistics of Study 1       ****************************************************
*****************************************************************************************************************************


*First, run regressions to include only those observations used in the regressions   ***

*All observations
preserve
gen baseline = treatment==0
gen choice = treatment==1
gen ownership = treatment==2
quietly reghdfe guessup i.owned##i.post##i.treatment bayesian_posterior bayes_down bayes_up, absorb(idstock i.period) cluster(id)
logout, save(Table_SS_all) excel replace: sum guessup owned post baseline choice ownership bayesian_posterior bayes_up bayes_down if e(sample)==1 
restore

*************************************************  	ENDS HERE  ***********************************************************
